home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1994 June / PC Plus Super CD coverdisc Issue 93 June 1994.iso / suprdisk / button / frmmains.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-04-02  |  7.8 KB  |  237 lines

  1. VERSION 2.00
  2. Begin Form frmMainSave 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Save"
  5.    ClientHeight    =   4095
  6.    ClientLeft      =   2340
  7.    ClientTop       =   2280
  8.    ClientWidth     =   5025
  9.    ClipControls    =   0   'False
  10.    ControlBox      =   0   'False
  11.    Height          =   4500
  12.    Left            =   2280
  13.    LinkTopic       =   "Form2"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   4095
  17.    ScaleWidth      =   5025
  18.    Top             =   1935
  19.    Width           =   5145
  20.    Begin CommandButton cmdSave 
  21.       Caption         =   "&SAVE"
  22.       Default         =   -1  'True
  23.       Height          =   420
  24.       Left            =   600
  25.       TabIndex        =   4
  26.       Top             =   3510
  27.       Width           =   990
  28.    End
  29.    Begin CommandButton cmdDontSave 
  30.       Caption         =   "&DON'T SAVE"
  31.       Height          =   420
  32.       Left            =   1800
  33.       TabIndex        =   5
  34.       Top             =   3510
  35.       Width           =   1365
  36.    End
  37.    Begin OptionButton optChoice 
  38.       Caption         =   "BUTTON to BITMAP then BITMAP to DISK"
  39.       Height          =   330
  40.       Index           =   8
  41.       Left            =   525
  42.       TabIndex        =   3
  43.       Top             =   2700
  44.       Visible         =   0   'False
  45.       Width           =   4065
  46.    End
  47.    Begin OptionButton optChoice 
  48.       Caption         =   "MASTER BITMAP to DISK"
  49.       Height          =   330
  50.       Index           =   4
  51.       Left            =   525
  52.       TabIndex        =   2
  53.       Top             =   2160
  54.       Visible         =   0   'False
  55.       Width           =   4215
  56.    End
  57.    Begin OptionButton optChoice 
  58.       Caption         =   "BUTTON to MASTER BITMAP"
  59.       Height          =   330
  60.       Index           =   2
  61.       Left            =   525
  62.       TabIndex        =   1
  63.       Top             =   1665
  64.       Visible         =   0   'False
  65.       Width           =   4215
  66.    End
  67.    Begin OptionButton optChoice 
  68.       Caption         =   "BUTTON to DISK"
  69.       Height          =   375
  70.       Index           =   1
  71.       Left            =   525
  72.       TabIndex        =   0
  73.       Top             =   1170
  74.       Visible         =   0   'False
  75.       Width           =   3840
  76.    End
  77.    Begin CommandButton cmdCancel 
  78.       Cancel          =   -1  'True
  79.       Caption         =   "CANCEL"
  80.       Height          =   420
  81.       Left            =   3375
  82.       TabIndex        =   7
  83.       Top             =   3510
  84.       Width           =   990
  85.    End
  86.    Begin Label Label1 
  87.       FontBold        =   -1  'True
  88.       FontItalic      =   0   'False
  89.       FontName        =   "MS Sans Serif"
  90.       FontSize        =   9.75
  91.       FontStrikethru  =   0   'False
  92.       FontUnderline   =   -1  'True
  93.       ForeColor       =   &H00008000&
  94.       Height          =   735
  95.       Left            =   825
  96.       TabIndex        =   6
  97.       Top             =   225
  98.       Width           =   3240
  99.    End
  100. Option Explicit
  101. Dim Selection As Integer
  102. Sub cmdCancel_Click ()
  103.     frmMainSave.Tag = CANCEL_SAVE
  104.     frmMainSave.Hide
  105. End Sub
  106. Sub cmdDontSave_Click ()
  107.     Select Case frmMainSave.Tag
  108.         Case 3, 9, 13
  109.             ButtonChanged = False
  110.         Case 4, 13
  111.             BitMap.Changed = False
  112.     End Select
  113.     frmMainSave.Tag = NOT_SAVED
  114.     frmMainSave.Hide
  115. End Sub
  116. Sub cmdSave_Click ()
  117.     Dim z As Integer
  118.     Select Case Selection
  119.         Case 1      'Save individual buttons to disk
  120.             Save_To_Disk S_TYPE_INDIVIDUAL
  121.         Case 2      'Save buttons to the master bitmap
  122.             If BitMap.Buttons = False Then  'No bitmap initialized
  123.                 frmSaveBit.Show 1
  124.             End If
  125.             If BitMap.Buttons > 0 Then      'Bitmap initialized
  126.                 Save_To_BitMap
  127.                 frmMainSave.Tag = SAVED
  128.             Else
  129.                 frmMainSave.Tag = CANCEL_SAVE
  130.             End If
  131.         Case 4     'Save the master bitmap to disk
  132.             Save_To_Disk S_TYPE_BITMAP
  133.         Case 8     'Save the button to the master bitmap then save the master bitmap
  134.             If BitMap.Buttons = False Then  'No bitmap initialized
  135.                 frmSaveBit.Show 1
  136.             End If
  137.             If BitMap.Buttons > 0 Then      'Bitmap initialized
  138.                 Save_To_BitMap
  139.                 frmMainSave.Tag = SAVED
  140.                 Save_To_Disk S_TYPE_BITMAP
  141.             Else
  142.                 frmMainSave.Tag = CANCEL_SAVE
  143.             End If
  144.         Case Else
  145.             MsgBox "Nothing selected"
  146.             Exit Sub
  147.     End Select
  148.     frmMainSave.Hide
  149. End Sub
  150. Sub Form_Activate ()
  151.     Dim n As Integer
  152.     For n = 0 To 3
  153.         optChoice(2 ^ n).Visible = (frmMainSave.Tag And (2 ^ n)) > 0
  154.         If Not optChoice(2 ^ n).Visible Then optChoice(2 ^ n) = False
  155.     Next n
  156.     If Selection > 0 Then
  157.         If Not optChoice(Selection).Visible Then Selection = False
  158.     End If
  159.     Select Case frmMainSave.Tag
  160.         Case 3: Label1 = BUT_CHANGED & SAVE_CHANGES
  161.         Case 4: Label1 = BIT_CHANGED & SAVE_CHANGES
  162.         Case 9: Label1 = BUT_CHANGED & SAVE_CHANGES
  163.         Case 13: Label1 = BOTH_CHANGED & SAVE_CHANGES
  164.         Case Else
  165.             Label1 = "Please select an option."
  166.     End Select
  167.     HelpItem = 12
  168. End Sub
  169. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  170.     If KeyCode = &H70 Then
  171.         Cheap_Help Format$(HelpItem)
  172.     End If
  173. End Sub
  174. Sub Form_Load ()
  175.     Position_Form frmMainSave
  176.     KeyPreview = True
  177. End Sub
  178. Sub optChoice_Click (Index As Integer)
  179.     Selection = Index
  180. End Sub
  181. Sub optChoice_DblClick (Index As Integer)
  182.     Selection = Index
  183.     cmdSave_Click
  184. End Sub
  185. Sub Save_To_BitMap ()
  186.     Dim n As Integer
  187.     Dim TempBox() As picturebox
  188.     Dim NumButtons As Integer
  189.     Dim Edge
  190.     Dim Gap
  191.     Dim FrameHeight As Integer
  192.     'Height of the picturebox top border + bottom border in pixels
  193.     FrameHeight = GetSystemMetrics(SM_CYBORDER) * 2
  194.     'eg
  195.     'If the border is 1 then the edge of the master bitmap will be 1
  196.     'and the gap between buttons on the bitmap will be 2
  197.     Edge = BitMap.Border
  198.     Gap = BitMap.Border * 2
  199.     'If the disabled button is to be saved then update it
  200.     If BitMap.Buttons And 4 Then Update_Button
  201.     'Allow for the top border of the bitmap
  202.     If BitMap.Position = 0 Then BitMap.Position = BitMap.Border
  203.     'Find out how many buttons to save and redim TempBox to hold them
  204.     For n = 0 To 2
  205.         If BitMap.Buttons And (2 ^ n) Then NumButtons = NumButtons + 1
  206.     Next n
  207.     ReDim TempBox(NumButtons - 1)
  208.     'Reset NumButtons to zero so we can use it again
  209.     NumButtons = 0
  210.     For n = 0 To 2
  211.         If BitMap.Buttons And 2 ^ n Then
  212.         Set TempBox(NumButtons) = B(n)
  213.         NumButtons = NumButtons + 1
  214.         End If
  215.     Next n
  216.     'Adjust the height of the master bitmap to hold the new button
  217.     frmBitMap!picBitMap.Height = BitMap.Position + BitMap.ButtonHeight + Gap + FrameHeight
  218.     'Copy the buttons
  219.     For n = 0 To UBound(TempBox)
  220.         BitBlt frmBitMap!picBitMap.hDC, Edge + (BitMap.ButtonWidth * n) + (Gap * n), BitMap.Position, Edge + (BitMap.ButtonWidth * (n + 1)) + (Gap * n), Edge + BitMap.ButtonHeight, TempBox(n).hDC, 0, 0, SRCCOPY
  221.     Next n
  222.     'save the position for the next button
  223.     BitMap.Position = BitMap.Position + BitMap.ButtonHeight + Gap
  224.     'Change the flags
  225.     BitMap.Changed = True
  226.     ButtonChanged = False
  227.     BitMapLoaded = True
  228.     Editing = False
  229. End Sub
  230. Sub Save_To_Disk (sType As Integer)
  231.     frmSave.Tag = sType
  232.     frmSave.Show 1
  233.     frmMainSave.Tag = frmSave.Tag   'Let the calling form know what's happened
  234.     If frmMainSave.Tag = NOT_SAVED Then cmdDontSave_Click
  235.     Unload frmSave
  236. End Sub
  237.